<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    let person = ['李白', '雅典娜', '安琪拉', '李白', '诸葛亮', '安琪拉']
    let nameObj = person.reduce((pre, cur) => {
        console.log("pre:",pre," cur:",cur)
        if (cur in pre) {
            pre[cur]++
        } else {
            pre[cur] = 1
        }
        return pre
    }, {})
    console.log(nameObj) // {李白: 2, 雅典娜: 1, 安琪拉: 2, 诸葛亮: 1}
</script>
</body>
</html>